package treemodel.line;

import document.Context;
import treemodel.Unit;
import treeview.NodeView;
import treeview.container.WrappedHorizontalContainer;

import java.util.ArrayList;

/**
 * Created by Pavel Nikolaev
 */
public class WrappedLine extends GeneralLine {
    private ArrayList<Unit> createWordRepresentation() {
        ArrayList<Unit> newUnits = new ArrayList<Unit>();
        for (Unit unit : myUnits) {
            newUnits.addAll(unit.breakToWords());
        }
        return newUnits;
    }

    public void prepareForWrapping() {
        myUnits = createWordRepresentation();
    }

    @Override
    public NodeView createView(Context context) {
        return new WrappedHorizontalContainer(myUnits, context);
    }
}
